var isPalindrome = function(x) {
    let s = String(x).split('');
    let i = 0;
    let j = s.length - 1;
    while (i < j) {
        if (s[i] !== s[j]) return false;
        i++;
        j--;
    }
    return true;

};

var isPalindrome = function(x) {
    if (x < 0 || (x % 10 === 0 && x != 0)) return false;
    let reversedNum = 0;
    while (x > reversedNum) {
        reversedNum = reversedNum * 10 + x % 10;
        x = parseInt(x / 10);
    }
    return x === reversedNum || x === parseInt(reversedNum / 10);
}

console.log(isPalindrome(121))